package com.shujia.java.day10.demo2;

public class Dog extends Pet {
    // 为了区分狗和猫 分别加一个属性
    private String kind;

    public Dog() {
    }

    public Dog(String name, int health, String kind) {
        super(name, health);
        this.kind = kind;
    }

    public String getKind() {
        return kind;
    }

    public void setKind(String kind) {
        this.kind = kind;
    }

    @Override
    public void eat() {
        //同一个方法 不同的实例有不同的实现
        System.out.println("狗吃骨头");
        System.out.println("健康值+5");
        super.setHealth(super.getHealth()+5);

        System.out.println(getName()+"健康值为:"+super.getHealth());
    }
    @Override
    public void play() {
        System.out.println("狗玩飞盘");
        //玩之后减健康值
        System.out.println("健康值-10");
        super.setHealth(super.getHealth()-10);
        if(super.getHealth()<=0){
            System.out.println(getName()+"健康值为:"+0);
        }else{
            System.out.println(getName()+"健康值为:"+super.getHealth());
        }
    }
}
